from langchain_community.document_loaders import TextLoader
from langchain_text_splitters import CharacterTextSplitter

from utils.faissutils import FAISSDBUtils

qa = FAISSDBUtils()
# # 文档加载
# loder = TextLoader('新闻.txt',encoding='utf-8')
# # 加载文档
# docm = loder.load()
#
# # 切分
# text_spliter = CharacterTextSplitter(separator='\n',chunk_size=100,chunk_overlap=0)
# # 对文档进行切分
# res = text_spliter.split_documents(docm)
# qa.add(res,"new_index")
print(qa.search("挣扎飞行多久?", 1, "new_index"))
